package com.example.springboottools.utils;

import cn.hutool.core.collection.CollUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.example.springboottools.entiy.ExcelExportUtil;
import org.apache.commons.collections.CollectionUtils;
import sun.misc.BASE64Encoder;

import java.io.*;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.*;
import java.util.concurrent.*;
import java.util.stream.Collectors;

public class PicDownUtils {



    public static void main(String[] args) {
//        File file = new File("D:\\staples\\日常记录\\工作记录\\2024\\09\\25\\html_all_v1");
//        File[] files = file.listFiles();
//        for (File file1 : files) {
//            File[] files1 = file1.listFiles();
//            for (File file2 : files1) {
//                File[] files2 = file2.listFiles();
//                for (File file3 : files2) {
//                    String ss = file3.getName();
//                    String substring = ss.substring(0, ss.lastIndexOf("."));
//                    String substring1 = substring.substring(substring.lastIndexOf("_")+1);
//                    file3.renameTo(new File(file3.getParent() + "\\" + substring1 + ".jpg"));
//                }
//            }
//        }


//        String ss ="7701147298EA_5";
//      String  name1 = org.apache.commons.lang3.StringUtils.substring(ss,0,ss.lastIndexOf("_"));
//
//        System.out.println(name1);

        //readPicShiBeiTest();
       // readPicHtmlShiBeiTest();
       // readPicShiBeiJsonTest();
      //  readHtmlShiBeiJsonTest();
      //  readPicShiBeiJsonTest();
        readHtmlExcelDelFirstPic();
    }

    public static void readHtmlExcelDelFirstPic() {
        String excelPath = "D:\\staples\\日常记录\\工作记录\\2024\\10\\14\\html\\html-v1-1014.xls";
        File excelFile = new File(excelPath);
        String[] nameStr = {"SKU", "PHLAN", "PHHTM"};
        List<Map<String, Object>> excelMapList = ReadExcel.readExcel1(excelFile, nameStr, 1, 0);
        List<Map> mapListAll = new ArrayList<>();
        for (Map<String, Object> map : excelMapList) {
            Object o = map.get("PHHTM");
            if (o != null){
                String url = o + "";
                String[] split = url.split("<br />");
                if (split.length > 1){
                    split[0] = "";
                }
                Map<String,Object> map1 = map;
                String join = String.join("<br />", split);
                String s = join.replaceFirst("<br />", "");
                map1.put("PHHTM",String.join("<br />", s));
                mapListAll.add(map1);
            }
        }
        ExcelExportUtil excelExportUtil = new ExcelExportUtil();
        String title = "title";
        //各个列的表头
        String[] heardList = {"商品编码","语言","html值"};
        //各个列的元素key值
        String[] heardKey = {"SKU", "PHLAN", "PHHTM"};
        //需要填充的数据信息
        excelExportUtil.setTitle(title);
        excelExportUtil.setHeardList(heardList);
        excelExportUtil.setHeardKey(heardKey);
        excelExportUtil.setData(mapListAll);
        try {
            String s = System.currentTimeMillis() + "html";
            excelExportUtil.exportExportLocal("D:\\staples\\日常记录\\工作记录\\2024\\10\\14\\html\\new_excel\\" + s + ".xls");
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public static void readPicTest() {
        String excelPath = "D:\\staples\\日常记录\\工作记录\\2024\\04\\29\\pic1\\商品主图.xls";
        File excelFile = new File(excelPath);
        String[] nameStr = {"SKU", "UNITEA", "PIPICLK"};
        List<Map<String, Object>> excelMapList = ReadExcel.readExcel1(excelFile, nameStr, 1, 0);
        for (Map<String, Object> map : excelMapList) {
            String name = map.get("SKU") + "";
            String unitea = map.get("UNITEA") + "";
            //String pipiclk = map.get("PIPICLK") + "";
            String pipiclk = map.get("PIPICLK")+"";
            //String _url = "http://newvp-pic.staplescn.com/static_adv/ftp_product_img/" + pipiclk + "";
            String _url = "http://newvp-pic.staplescn.com/static_adv/ftp_product_img/" + pipiclk + "";
            try {
                String replace = pipiclk.replace("/", "");
                String s = "D:\\staples\\日常记录\\工作记录\\2024\\04\\29\\pic1\\pic\\" + name+unitea;
                File file = new File(s);
                if (!file.isDirectory()) {
                    file.mkdirs();
                }
                String path = "D:\\staples\\日常记录\\工作记录\\2024\\04\\29\\pic1\\pic\\" + name +unitea+ "\\" + replace;
                downloadPicturePic(_url, path);
            } catch (Exception e) {
                e.printStackTrace();
                System.out.println(name + "下载异常");
            }

        }
    }


    public static void readPicShiBei() {
        // String excelPath = "C:\\Users\\sh102909\\Desktop\\1111\\1111.xls";
        String excelPath = "D:\\staples\\日常记录\\工作记录\\2024\\09\\22\\all_pic_html\\新建文件夹\\全包主图.xls";
        File excelFile = new File(excelPath);
        String[] nameStr = {"SKU", "PAYLOAD"};
        List<Map<String, Object>> excelMapList = ReadExcel.readExcel1(excelFile, nameStr, 1, 0);
        for (Map<String, Object> map : excelMapList) {
            String name = map.get("SKU") + "";
            Object picStr = JSONObject.parseObject(map.get("PAYLOAD") + "").get("PIC_MAIN");
            JSONArray picArray = JSONArray.parseArray(picStr + "");
            //String _url = "http://newvp-pic.staplescn.com/static_adv/ftp_product_img/" + pipiclk + "";

            picArray.forEach(item->{
                JSONObject jsonObject = JSONObject.parseObject(item + "");
                String url = jsonObject.getString("URL");
                String seq = jsonObject.getString("SEQ");
                String unitea = jsonObject.getString("UM");
                try {
                    String s = "D:\\staples\\日常记录\\工作记录\\2024\\04\\29\\pic\\pic\\" + name+unitea;
                    File file = new File(s);
                    if (!file.isDirectory()) {
                        file.mkdirs();
                    }
                    //String path = "D:\\staples\\日常记录\\工作记录\\2024\\04\\29\\pic\\pic\\" + name +unitea+ "\\" + name+unitea+"_"+seq+"_xnl"+".jpg";
                    String path = "D:\\staples\\日常记录\\工作记录\\2024\\04\\29\\pic\\pic\\" + name +unitea+ "\\" +seq+".jpg";
                    downloadPicturePic(url, path);
                } catch (Exception e) {
                    e.printStackTrace();
                    System.out.println(name + "下载异常");
                }
            });
        }
    }
    public static void readPicShiBeiTest() {
        // String excelPath = "C:\\Users\\sh102909\\Desktop\\1111\\1111.xls";
        String excelPath = "D:\\staples\\日常记录\\工作记录\\2024\\09\\22\\all_pic_html\\新建文件夹\\pic.xls";
        File excelFile = new File(excelPath);
        String[] nameStr = {"SKU", "UNITEA", "PIPICLK"};
        List<Map<String, Object>> excelMapList = ReadExcel.readExcel1(excelFile, nameStr, 1, 0);
        List<List<Map<String, Object>>> split = CollUtil.split(excelMapList, 10);
         ExecutorService pool = new ThreadPoolExecutor(32,
                32,
                1,
                TimeUnit.MINUTES,
                new ArrayBlockingQueue<Runnable>(200)
        );
        for (List<Map<String, Object>> maps : split) {
            Future<?> submit = pool.submit(new Runnable() {
                @Override
                public void run() {
                    String threadName = Thread.currentThread().getName();
                    System.out.println("当前线程:" + threadName);
                    List<String> skuList = new ArrayList<>();
                    for (Map<String, Object> map : maps) {
                        String name = map.get("SKU") + "";
                        String unitea = map.get("UNITEA") + "";
                        //String pipiclk = map.get("PIPICLK") + "";
                        // String pipiclk = map.get("PIPICLK") + ".jpg";
                        try {
                            Object picStr = JSONObject.parseObject(map.get("PIPICLK") + "").get("PIC_MAIN");
                            JSONArray picArray = JSONArray.parseArray(picStr + "");
                            //String _url = "http://newvp-pic.staplescn.com/static_adv/ftp_product_img/" + pipiclk + "";

                            picArray.forEach(item -> {
                                JSONObject jsonObject = JSONObject.parseObject(item + "");
                                String url = jsonObject.getString("URL");
                                String seq = jsonObject.getString("SEQ");
                                try {
                                    String s = "D:\\staples\\日常记录\\工作记录\\2024\\09\\22\\all_pic_html\\新建文件夹\\pic\\" + name + unitea;
                                    File file = new File(s);
                                    if (!file.isDirectory()) {
                                        file.mkdirs();
                                    }
                                    //String path = "D:\\staples\\日常记录\\工作记录\\2024\\09\\22\\all_pic_html\\新建文件夹\\pic\\" + name + unitea + "\\" + name + unitea + "_" + seq +"_xnl"+ ".jpg";
                                    String path = "D:\\staples\\日常记录\\工作记录\\2024\\09\\22\\all_pic_html\\新建文件夹\\pic\\" + name + unitea + "\\"  + seq + ".jpg";
                                    downloadPicturePic(url, path);
                                } catch (Exception e) {
                                    skuList.add(name);
                                    e.printStackTrace();
                                    System.out.println(name + "下载异常");
                                }
                            });
                        } catch (Exception e) {
                            skuList.add(name);
                            e.printStackTrace();
                            System.out.println(name + "下载异常");
                        }

                    }
                    List<Map> mapListAll = new ArrayList<>();
                    if (CollectionUtils.isNotEmpty(skuList)) {
                        mapListAll = skuList.stream().map(item -> {
                            Map<String, Object> map = new HashMap<>();
                            map.put("SKU", item);
                            return map;
                        }).collect(Collectors.toList());
                        ExcelExportUtil excelExportUtil = new ExcelExportUtil();
                        String title = "title";
                        //各个列的表头
                        String[] heardList = {"商品编码"};
                        //各个列的元素key值
                        String[] heardKey = {"SKU"};
                        //需要填充的数据信息
                        excelExportUtil.setTitle(title);
                        excelExportUtil.setHeardList(heardList);
                        excelExportUtil.setHeardKey(heardKey);
                        excelExportUtil.setData(mapListAll);
                        try {
                            String s = threadName + System.currentTimeMillis() + "pic_error";
                            excelExportUtil.exportExportLocal("D:\\staples\\日常记录\\工作记录\\2024\\09\\22\\all_pic_html\\新建文件夹\\pic_error\\" + s + ".xls");
                        } catch (IOException e) {
                            throw new RuntimeException(e);
                        }
                        System.out.println(JSON.toJSONString(mapListAll));
                    }
                }
            });
        }

    }


    //解析拾贝详图报文
    public static void readPicHtmlShiBeiTest() {
        // String excelPath = "C:\\Users\\sh102909\\Desktop\\1111\\1111.xls";
        String excelPath = "D:\\staples\\日常记录\\工作记录\\2024\\09\\25\\html_all\\新建文件夹\\html_2.xls";
        File excelFile = new File(excelPath);
        String[] nameStr = {"SKU", "UNITEA", "PIPICLK"};
        List<Map<String, Object>> excelMapList = ReadExcel.readExcel1(excelFile, nameStr, 1, 0);
        List<List<Map<String, Object>>> split = CollUtil.split(excelMapList, 20);
        ExecutorService pool = new ThreadPoolExecutor(5,
                32,
                1,
                TimeUnit.MINUTES,
                new ArrayBlockingQueue<Runnable>(200)
        );

        for (List<Map<String, Object>> maps : split) {
            pool.execute(new Runnable() {
                @Override
                public void run() {
                    String threadName = Thread.currentThread().getName();
                    System.out.println("当前线程:"+ threadName);
                    List<String> skuList = new ArrayList<>();
                    for (Map<String, Object> map : maps) {
                        String name = map.get("SKU") + "";
                        String unitea = map.get("UNITEA") + "";
                        //String pipiclk = map.get("PIPICLK") + "";
                        // String pipiclk = map.get("PIPICLK") + ".jpg";
                        try {
                            Object picStr = JSONObject.parseObject(map.get("PIPICLK") + "").get("PIC_DETAIL");
                            JSONArray picArray = JSONArray.parseArray(picStr + "");
                            //String _url = "http://newvp-pic.staplescn.com/static_adv/ftp_product_img/" + pipiclk + "";

                            picArray.forEach(item->{
                                JSONObject jsonObject = JSONObject.parseObject(item + "");
                                String url = jsonObject.getString("URL");
                                String seq = jsonObject.getString("SEQ");
                                try {
                                    String s = "D:\\staples\\日常记录\\工作记录\\2024\\09\\25\\html_all\\htm_jpg\\html_2\\"+ name;
                                    File file = new File(s);
                                    if (!file.isDirectory()) {
                                        file.mkdirs();
                                    }
                                   // String path = "D:\\staples\\日常记录\\工作记录\\2024\\09\\25\\html_all\\htm_jpg\\html_2\\"  + name + "\\" + name+unitea+"_"+seq+"_xnl"+".jpg";
                                    String path = "D:\\staples\\日常记录\\工作记录\\2024\\09\\25\\html_all\\htm_jpg\\html_2\\"  + name + "\\" +seq+".jpg";
                                    downloadPicturePic(url, path);
                                } catch (Exception e) {
                                    e.printStackTrace();
                                    System.out.println(name + "下载异常");
                                }
                            });
                        }catch (Exception e){
                            skuList.add(name);
                            e.printStackTrace();
                            System.out.println(name + "下载异常");
                        }

                    }
                    List<Map> mapListAll =new ArrayList<>();
                    if (CollectionUtils.isNotEmpty(skuList)){
                        mapListAll = skuList.stream().map(item -> {
                            Map<String, Object> map = new HashMap<>();
                            map.put("SKU", item);
                            return map;
                        }).collect(Collectors.toList());
                        ExcelExportUtil excelExportUtil=new ExcelExportUtil();
                        String title="title";
                        //各个列的表头
                        String[] heardList={"商品编码"};
                        //各个列的元素key值
                        String[] heardKey={"SKU"};
                        //需要填充的数据信息
                        excelExportUtil.setTitle(title);
                        excelExportUtil.setHeardList(heardList);
                        excelExportUtil.setHeardKey(heardKey);
                        excelExportUtil.setData(mapListAll);
                        try {
                            String s = threadName + System.currentTimeMillis()+"pic_error";
                            excelExportUtil.exportExportLocal("D:\\staples\\日常记录\\工作记录\\2024\\09\\25\\html_all\\htm_jpg\\html_2_error\\"+s+".xls");
                        } catch (IOException e) {
                            throw new RuntimeException(e);
                        }
                        System.out.println(JSON.toJSONString(mapListAll));
                    }
                }
            });
        }


    }
    //解析拾贝主图图报文
    public static void readPicShiBeiJsonTest() {
        String filePath = "D:\\staples\\日常记录\\工作记录\\2024\\09\\30\\aaa.txt";
        StringBuilder content = new StringBuilder();
        try (BufferedReader reader = new BufferedReader(new FileReader(filePath))) {
            String line;
            while ((line = reader.readLine()) != null) {
                content.append(line).append("\n");
            }
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        String jsonStr = content.toString();
//        JSONObject jsonObject1 = JSONObject.parseObject(jsonStr);
//        JSONArray array = new JSONArray();
//        array.add(jsonObject1);
        JSONArray array = JSONArray.parseArray(jsonStr);
        List<Map<String, Object>> excelMapList = new ArrayList<>();
        array.forEach(item->{
            JSONObject jsonObject = JSONObject.parseObject(item+"");
            //String sku = jsonObject.getString("PROSEQ");
            String sku = jsonObject.getString("SKU");
            String payload = jsonObject.getString("PAYLOAD");
            Map<String, Object> map = new HashMap<>();
            map.put("SKU", sku);
            map.put("UNITEA", "EA");
            map.put("PIPICLK", payload);
            excelMapList.add(map);
        });
        System.out.println(excelMapList);
        List<List<Map<String, Object>>> split = CollUtil.split(excelMapList, 1000);
        ExecutorService pool = new ThreadPoolExecutor(1,
                1,
                1,
                TimeUnit.MINUTES,
                new ArrayBlockingQueue<Runnable>(200)
        );
        for (List<Map<String, Object>> maps : split) {
           pool.execute(new Runnable() {
                @Override
                public void run() {
                    String threadName = Thread.currentThread().getName();
                    System.out.println("当前线程:" + threadName);
                    List<String> skuList = new ArrayList<>();
                    for (Map<String, Object> map : maps) {
                        String name = map.get("SKU") + "";
                        String unitea = map.get("UNITEA") + "";
                        //String pipiclk = map.get("PIPICLK") + "";
                        // String pipiclk = map.get("PIPICLK") + ".jpg";
                        try {
                            Object picStr = JSONObject.parseObject(map.get("PIPICLK") + "").get("PIC_MAIN");
                            System.out.println("商品编码："+name+"商品主图链接："+JSON.toJSONString(picStr));
                            JSONArray picArray = JSONArray.parseArray(picStr + "");
                            //String _url = "http://newvp-pic.staplescn.com/static_adv/ftp_product_img/" + pipiclk + "";
                            if (CollectionUtils.isEmpty(picArray)) skuList.add(name);
                            picArray.forEach(item -> {
                                JSONObject jsonObject = JSONObject.parseObject(item + "");
                                String url = jsonObject.getString("URL");
                                String seq = jsonObject.getString("SEQ");
                                try {
                                    String s = "D:\\staples\\日常记录\\工作记录\\2024\\09\\30\\pic\\" + name + unitea;
                                    File file = new File(s);
                                    if (!file.isDirectory()) {
                                        file.mkdirs();
                                    }
                                   // String path = "D:\\staples\\日常记录\\工作记录\\2024\\09\\22\\pd_all_0925_v2\\pic\\" + name + unitea + "\\" + name + unitea + "_" + seq+"_xnl" + ".jpg";
                                    String path = "D:\\staples\\日常记录\\工作记录\\2024\\09\\30\\pic\\" + name + unitea + "\\"  + seq+ ".jpg";
                                    downloadPicturePic(url, path);
                                } catch (Exception e) {
                                    skuList.add(name);
                                    e.printStackTrace();
                                    System.out.println(name + "下载异常");
                                }
                            });
                        } catch (Exception e) {
                            skuList.add(name);
                            e.printStackTrace();
                            System.out.println(name + "下载异常");
                        }

                    }
                    List<Map> mapListAll = new ArrayList<>();
                    if (CollectionUtils.isNotEmpty(skuList)) {
                        mapListAll = skuList.stream().map(item -> {
                            Map<String, Object> map = new HashMap<>();
                            map.put("SKU", item);
                            return map;
                        }).collect(Collectors.toList());
                        ExcelExportUtil excelExportUtil = new ExcelExportUtil();
                        String title = "title";
                        //各个列的表头
                        String[] heardList = {"商品编码"};
                        //各个列的元素key值
                        String[] heardKey = {"SKU"};
                        //需要填充的数据信息
                        excelExportUtil.setTitle(title);
                        excelExportUtil.setHeardList(heardList);
                        excelExportUtil.setHeardKey(heardKey);
                        excelExportUtil.setData(mapListAll);
                        try {
                            String s = threadName + System.currentTimeMillis() + "pic_error";
                            excelExportUtil.exportExportLocal("D:\\staples\\日常记录\\工作记录\\2024\\09\\30\\pic_error\\" + s + ".xls");
                        } catch (IOException e) {
                            throw new RuntimeException(e);
                        }
                        System.out.println(JSON.toJSONString(mapListAll));
                    }
                }
            });
        }
        pool.shutdown();

    }
    public static void readHtmlShiBeiJsonTest() {
        String filePath = "D:\\staples\\日常记录\\工作记录\\2024\\09\\26\\pool_test\\long_html_0926.json";
        StringBuilder content = new StringBuilder();
        try (BufferedReader reader = new BufferedReader(new FileReader(filePath))) {
            String line;
            while ((line = reader.readLine()) != null) {
                content.append(line).append("\n");
            }
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        String jsonStr = content.toString();
        JSONArray array = JSONArray.parseArray(jsonStr);
        List<Map<String, Object>> excelMapList = new ArrayList<>();
        array.forEach(item->{
            JSONObject jsonObject = JSONObject.parseObject(item+"");
            String sku = jsonObject.getString("SKU");
            String payload = jsonObject.getString("PAYLOAD");
            Map<String, Object> map = new HashMap<>();
            map.put("SKU", sku);
            map.put("UNITEA", "EA");
            map.put("PIPICLK", payload);
            excelMapList.add(map);
        });
        System.out.println(excelMapList);
        List<List<Map<String, Object>>> split = CollUtil.split(excelMapList, 2);
        ExecutorService pool = new ThreadPoolExecutor(5,
                32,
                1,
                TimeUnit.MINUTES,
                new ArrayBlockingQueue<Runnable>(200)
        );
        for (List<Map<String, Object>> maps : split) {
            Future<?> submit = pool.submit(new Runnable() {
                                               @Override
                                               public void run() {

                                                   String threadName = Thread.currentThread().getName();
                                                   System.out.println("当前线程:"+ threadName);
                                                   List<String> skuList = new ArrayList<>();
                                                   for (Map<String, Object> map : maps) {
                                                       String name = map.get("SKU") + "";
                                                       String unitea = map.get("UNITEA") + "";
                                                       //String pipiclk = map.get("PIPICLK") + "";
                                                       // String pipiclk = map.get("PIPICLK") + ".jpg";
                                                       try {
                                                           Object picStr = JSONObject.parseObject(map.get("PIPICLK") + "").get("PIC_DETAIL");
                                                           JSONArray picArray = JSONArray.parseArray(picStr + "");
                                                           //String _url = "http://newvp-pic.staplescn.com/static_adv/ftp_product_img/" + pipiclk + "";
                                                           System.out.println("下载商品"+name+"对应链接"+JSON.toJSONString(picArray));
                                                           if (CollectionUtils.isEmpty(picArray))skuList.add(name);
                                                           picArray.forEach(item->{
                                                               JSONObject jsonObject = JSONObject.parseObject(item + "");
                                                               String url = jsonObject.getString("URL");
                                                               String seq = jsonObject.getString("SEQ");
                                                               try {
                                                                   String s = "D:\\staples\\日常记录\\工作记录\\2024\\09\\26\\pool_test\\loack_html\\"+ name;
                                                                   File file = new File(s);
                                                                   if (!file.isDirectory()) {
                                                                       file.mkdirs();
                                                                   }
                                                                   //String path = "D:\\staples\\日常记录\\工作记录\\2024\\09\\26\\pool_test\\loack_html\\"  + name + "\\" + name+unitea+"_"+seq+"_xnl"+".jpg";
                                                                   String path = "D:\\staples\\日常记录\\工作记录\\2024\\09\\26\\pool_test\\loack_html\\"  + name + "\\" +seq+".jpg";
                                                                   downloadPicturePic(url, path);
                                                               } catch (Exception e) {
                                                                   e.printStackTrace();
                                                                   System.out.println(name + "下载异常");
                                                               }
                                                           });
                                                       }catch (Exception e){
                                                           skuList.add(name);
                                                           e.printStackTrace();
                                                           System.out.println(name + "下载异常");
                                                       }

                                                   }
                                                   List<Map> mapListAll =new ArrayList<>();
                                                   if (CollectionUtils.isNotEmpty(skuList)){
                                                       mapListAll = skuList.stream().map(item -> {
                                                           Map<String, Object> map = new HashMap<>();
                                                           map.put("SKU", item);
                                                           return map;
                                                       }).collect(Collectors.toList());
                                                       ExcelExportUtil excelExportUtil=new ExcelExportUtil();
                                                       String title="title";
                                                       //各个列的表头
                                                       String[] heardList={"商品编码"};
                                                       //各个列的元素key值
                                                       String[] heardKey={"SKU"};
                                                       //需要填充的数据信息
                                                       excelExportUtil.setTitle(title);
                                                       excelExportUtil.setHeardList(heardList);
                                                       excelExportUtil.setHeardKey(heardKey);
                                                       excelExportUtil.setData(mapListAll);
                                                       try {
                                                           String s = threadName + System.currentTimeMillis()+"pic_error";
                                                           excelExportUtil.exportExportLocal("D:\\staples\\日常记录\\工作记录\\2024\\09\\26\\pool_test\\html_error\\"+s+".xls");
                                                       } catch (IOException e) {
                                                           throw new RuntimeException(e);
                                                       }
                                                       System.out.println(JSON.toJSONString(mapListAll));
                                                   }


                                               }
                                           }

            );

        }
        pool.shutdown();
        System.out.println("线程执行完毕");

    }
    private static void downloadPicturePic(String urlList, String path) {
        URL url = null;
        try {
            if (urlList.startsWith("//")) {
                urlList = "http:" + urlList;

            } else if (urlList.contains("https")) {
                urlList = urlList.replace("https", "http");

            }
            url = new URL(urlList);
            // HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
            // int responseCode = httpURLConnection.getResponseCode();
            //URLAvailability urlAvailability=new URLAvailability();
            //URL connect = urlAvailability.isConnect(urlList);
            DataInputStream dataInputStream = new DataInputStream(url.openStream());
            File file = new File(path);
            if (file.isDirectory()){}
            FileOutputStream fileOutputStream = new FileOutputStream(file);
            ByteArrayOutputStream output = new ByteArrayOutputStream();

            byte[] buffer = new byte[1024];
            int length;

            while ((length = dataInputStream.read(buffer)) > 0) {
                output.write(buffer, 0, length);
            }
            BASE64Encoder encoder = new BASE64Encoder();
            String encode = encoder.encode(buffer);//返回Base64编码过的字节数组字符串
            System.out.println(encode);
            fileOutputStream.write(output.toByteArray());
            dataInputStream.close();
            fileOutputStream.close();
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
